<template>
    <div> 
        <p>页面</p>
        <el-form :model="BannerForm" :rules="rules" ref="BannerForm" label-width="100px" class="demo-ruleForm">
  

            <el-form-item label="图片" prop="image">
                <UpLoadImg :action="action" :dialogImageUrl="BannerForm.image" @Sendimg1="sendimg2" ref="uploadimg" :fileList="fileList"></UpLoadImg>
            </el-form-item>

            <el-form-item label="轮播图位置" prop="type">
                <el-radio-group v-model="BannerForm.bannerType">
                    <el-radio  :label="1">首页</el-radio>
                    <el-radio  :label="0">文章页</el-radio>
                </el-radio-group>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="submitForm('BannerFrom')">确定</el-button>
                <el-button @click="resetForm('BannerForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
  
<script>
import { mapState} from 'vuex'
import UpLoadImg from '@/components/Background/UpLoadImg/uploadimg.vue'
export default {
    components:{
        UpLoadImg,
    },
    data() {
        return {
            action:this.$baseUrl +'/files/ArticleCoverImgUpload',
            BannerForm: {
                image: '',
                bannerType:'',
            },
        }
    },

    methods:{
        resetForm(){
            console.log(1)
        },
        async submitForm(){
            const res = await this.$axios.post("banner/AddBanner",this.BannerForm)
            if(res.code == "200"){
                this.$message.success(res.msg)
                this.$router.push('/banner')
            }
            else{
                this.$message.error(res.msg)
            }
        },
        sendimg2(val){
            this.BannerForm.image = val
        }

    }

}
</script>
  
<style scoped>
  
</style>